Socket
Socket
Sign inDemoInstall

mdast-util-heading-style

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-heading-style

mdast utility to get the style of a heading


Version published
Weekly downloads
114K
decreased by-14.51%
Maintainers
2
Weekly downloads
 
Created
Source

mdast-util-heading-style

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to get the style of a heading.

Install

npm:

npm install mdast-util-heading-style

Use

var style = require('mdast-util-heading-style')
var unified = require('unified')
var parse = require('remark-parse')

var processor = unified().use(parse)

style(processor.parse('# ATX').children[0]) // => 'atx'
style(processor.parse('# ATX #\n').children[0]) // => 'atx-closed'
style(processor.parse('ATX\n===').children[0]) // => 'setext'

style(processor.parse('### ATX').children[0]) // => null
style(processor.parse('### ATX').children[0], 'setext') // => 'setext'

API

style(node[, relative])

Get the heading style of a node.

Parameters
  • node (Node) — Node to parse
  • relative (string, optional) — Style to use for ambiguous headings (atx-headings with a level of three or more could also be setext)
Returns

string ('atx', 'atx-closed', or 'setext') — When an ambiguous heading is found, either relative or null is returned.

Security

Use of mdast-util-heading-style does not involve hast so there are no openings for cross-site scripting (XSS) attacks.

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 22 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc